function env_filt = expan_rms_filt(rms, window, hop, nyquist, eth)

freq = 20;
erro = 10;
meanrms = mean(rms);

if (erro <= eth) 
    error('O valor de ETH deve ser menor.');
end

while erro > eth
%0.015
    n = 6;
    wn = freq/nyquist;
    [B,A] = butter(n, wn, 'low');
    warning off
    env_filt = filtfilt(B, A, rms);
    warning on
    freq = freq + 5;

    erro = (sum( abs(rms(1:length(rms))-(env_filt(1:length(rms)))) / meanrms ))/length(rms);
     %fprintf(1,' Erro =  %4d\n',erro);
end
